<div class="page-header">
  <h1>Categorias del sistema</h1>
</div>
  <div class="pull-right">
    <%= link_to 'Nueva categoria', new_category_path, :class => "btn btn-primary btn-small" %>  
  </div>
<br>
<br>
<table class="table table-bordered table-striped">
  <tr>
    <th>Sección</th>
    <th>#</th>
    <th>Nombre</th>
    <th>Tipo</th>
    <th>Padre</th>
    <th></th>
    <th></th>
  </tr>

<% @categories.each do |category| %>
  <tr>
    <td><%= category.section.name %></td>
    <td><%= category.category_order %></td>
    <td><%= category.name %></td>
    <td><%= category.category_type %></td>
    <td><%= category.parent_category_id == nil ? "Si" : "No" %></td>
    <td><%= link_to 'Editar', edit_category_path(category) %></td>
    <td><%= link_to 'Eliminar', category, :confirm => '¿Está seguro?', :method => :delete %></td>
  </tr>
  <% category.subcategories.each do |subcategory| %>
      <tr>
        <td><%= subcategory.section.name %></td>
        <td><%= subcategory.category_order %></td>
        <td style="padding-left:20px"><%= subcategory.name %></td>
        <td><%= subcategory.category_type %></td>
        <td><%= subcategory.parent_category_id == nil ? "Si" : "No" %></td>
        <td><%= link_to 'Editar', edit_category_path(subcategory) %></td>
        <td><%= link_to 'Eliminar', subcategory, :confirm => '¿Está seguro?', :method => :delete %></td>
      </tr>
  <% end %>
<% end %>
</table>
